<?php
/**
 * 数据维护 - JBlog
 *
 * @copyright (c) 2008-2012 JBlog (www.lisijie.org)
 * @author lisijie <lisijie86@gmail.com>
 * @version $Id$
 */
class DataController extends BaseController {
	
	//重新生成日历表
	public function recalendarAction() {
		@set_time_limit(0);
		if ($this->input->do == 'exec') {
			$this->db->execute("TRUNCATE TABLE ".$this->db->getTable('calendar'));
			$sql = "SELECT id,dateline FROM ".$this->db->getTable('post')." WHERE `type` = 'blog' ORDER BY dateline ASC";
			$result = $this->db->getList($sql);
			$this->db->setTable('calendar');
			foreach($result as $row) {
				$this->db->add(array(
					'yearmonth' => JBlog::date($row['dateline'],'Ym'),
					'day' => JBlog::date($row['dateline'],'j'),
					'postid' => $row['id'],
				));
			}
			$this->prompt(__('日历重建完成'));
		}
	}
	
	//数据维护
	public function dbopAction() {
		
	}
	
	private function getTables() {
		return array(
				'jblog_attach' => __('附件表'),
				'jblog_calendar' => __('日历表'),
				'jblog_cate' => __('分类表'),
				'jblog_comment' => __('评论表'),
				'jblog_config' => __('配置信息'),
				'jblog_link' => __('友情链接'),
				'jblog_meta' => __('公用自定义域'),
				'jblog_post' => __('文章表'),
				'jblog_postmeta' => __('文章自定义域'),
				'jblog_search' => __('搜索结果缓存'),
				'jblog_tag' => __('标签表'),
				'jblog_tagpost' => __('标签文章关系表'),
				'jblog_user' => __('用户表')
		);
	}
}
?>